home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / PCRESEXT.C < prev    next >
Text File  |  1990-08-09  |  1KB  |  40 lines

  1. /**
  2. *
  3. *  Name         pcresext -- Exit but stay resident
  4. *
  5. *  Synopsis     pcresext(excode);
  6. *               int excode;       Exit code to return to DOS
  7. *
  8. *  Description  This function terminates the current process but makes
  9. *               the program resident as part of DOS.  The value of excode
  10. *               is passed to DOS (or the parent process) and may be
  11. *               inspected with either the errorlevel command or the
  12. *               PCWAIT function.
  13. *
  14. *  Version      1.0  (C)Copyright Blaise Computing Inc.  1983
  15. *
  16. **/
  17. #define utbyword(a,b)   (((a)<<8)|((b)&0x00ff))  /* a is high, b low   */
  18.  
  19. struct dreg
  20. {
  21.   unsigned ax,bx,cx,dx,si,di,ds,es;
  22. };
  23. #define DOSREG  struct dreg
  24.  
  25. int pcresext(excode)
  26. int excode;
  27. {
  28.  
  29.     DOSREG   reg;
  30.     unsigned size;
  31.     int      utinit(),pcshrink(),dos();
  32.  
  33.     pcshrink(&size);                   /* Get the program size         */
  34.     utinit(®);
  35.     reg.ax = utbyword(0x31,excode);    /* DOS function 31 (hex)        */
  36.     reg.dx = size;
  37.     dos(®);
  38.  
  39. }
  40.